<template>
  <van-nav-bar
    :fixed="true"
    :left-arrow="leftArrow"
    :title="title"
    :left-text="leftText"
    :border="border"
    :color="color"
    @click-right="searchKwds"
    @click-left="goBack"
  >
    <template #right>
      <van-icon name="search" size="20"/>
    </template>
  </van-nav-bar>
</template>

<script>
import Header from './LeftArrowHeader'

export default {
  name: 'NoLeftArrowHeader',
  components: {
    Header
  },
  props: {
    title: {
      type: String,
      default: undefined
    },
    leftText: {
      type: String,
      default: ''
    },
    rightText: {
      type: String,
      default: ''
    },
    leftArrow: {
      type: Boolean,
      default: false
    },
    search: {
      type: Boolean,
      default: false
    },
    border: {
      type: Boolean,
      default: true
    },
    color: {
      type: String,
      default: undefined
    },
    isAttachPath: {
      type: Boolean,
      default: false
    }
  },
  methods: {
    searchKwds() {
      this.$router.push('search')
    },
    goBack() {
      if (this.isAttachPath) {
        this.$router.push('/regulations')
      } else {
        this.$router.back()
      }
    }
  }
}
</script>

<style scoped lang="less" rel="stylesheet/less">
.van-nav-bar {
  position: fixed;

  /deep/ .van-nav-bar__title {
    color: #FFFFFF;
  }

  /deep/ .van-icon {
    color: #FFFFFF;
  }
}
</style>
